﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Models;

namespace UI
{
    public partial class PrpductUI : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Repeater1绑定数据显示数据
            if (!this.IsPostBack)
            {
                this.Repeater1.DataSource = ProductBLL.dat();
                this.Repeater1.DataBind();

            }
        }

        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            //执行增删改操作 && 跳转页面
            //删除
            if (e.CommandName == "deleat")
                {
                string  a = e.CommandArgument.ToString();
                int b = Convert.ToInt16(a);
                ProductBLL.s(b);
                this.Repeater1.DataSource = ProductBLL.dat();
                this.Repeater1.DataBind();

                }
            //添加
            else if (e.CommandName == "inster")
                {
                Response.Redirect("ProductIns.aspx");
                }
            //修改
            else if (e.CommandName == "update")
                {
                // string a = e.CommandArgument.ToString();
                //使用HttpCookie 进行页面传值
                HttpCookie cookie = new HttpCookie("userName",e.CommandArgument.ToString());
                Response.Cookies.Add(cookie);
                Response.Redirect("ProductUpdatet.aspx");
                }
        }
           
    }
}